/**
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.gitee.huangjianbo.supos.openapi.core.http.response;


import java.io.Serializable;

/**
 * @author tomcat
 * @version 1.0
 */
public final class Pagination implements Serializable {

    private static final long serialVersionUID = -8064217282736482657L;

    /**
     * 总记录数
     */
    private Integer total = 0;
    /**
     * 每页记录数
     */
    private Integer pageSize = 0;
    /**
     * 当前页码
     */
    private Integer current = 1;
    /**
     * 当前页码，某些接口返回参名称是这个
     */
    private Integer pageIndex = 1;
    /**
     * 当前页码，某些接口返回参名称是这个
     */
    private Integer pageNo = 1;

    public void setTotal(int total) {
        this.total = total;
    }

    public int getTotal() {
        return total;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setCurrent(int current) {
        this.current = current;
        this.pageIndex = current;
        this.pageNo = current;
    }

    public int getCurrent() {
        return current;
    }

    public void setPageIndex(int pageIndex) {
        this.pageIndex = pageIndex;
        this.current = pageIndex;
        this.pageNo = pageIndex;
    }

    public int getPageIndex() {
        return pageIndex;
    }

    public void setPageNo(int pageNo) {
        this.pageNo = pageNo;
        this.current = pageNo;
        this.pageIndex = pageNo;
    }

    public int getPageNo() {
        return pageNo;
    }

    /**
     * 是否有下一页
     *
     * @return 是或否
     */
    public boolean hasNext() {
        return Math.ceil((double) this.total / this.pageSize) > this.current;
    }
}
